package com.lanou3g.mynewstest.module.news;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;

import com.lanou3g.mynewstest.R;

import java.util.ArrayList;

/**
 * Created by dllo on 16/1/7.
 */
public class NewsFragment extends Fragment{
    private ViewPager vp;
    private TabLayout tb;
    private NewsAdapter adapter;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_news,null);
        vp= (ViewPager) view.findViewById(R.id.news_viewpager);
        tb= (TabLayout) view.findViewById(R.id.news_tablayout);
        adapter=new NewsAdapter(getActivity().getSupportFragmentManager(),getContext());
        vp.setAdapter(adapter);
        tb.setupWithViewPager(vp);
        tb.setTabTextColors(Color.BLACK, Color.RED);
        tb.setSelectedTabIndicatorColor(Color.RED);

        return view;
    }
}
